package main

import (
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strings"

	"github.com/alfredxing/calc/operators"

	"gitee.com/magus_iot/magus/calc/compute"
)

func main() {
	//fmt.Println(i, math.Sin(math.Pi/float64(i)))
	s := math.Pi / 100
	t := 0.0
	for i := 0; i < 200; i++ {
		t += s
		//fmt.Println(i, math.Sin(t))
	}
	fmt.Println(math.Sin(math.Pi / 2))
	return

	if len(os.Args) > 1 {
		input := strings.Replace(strings.Join(os.Args[1:], ""), " ", "", -1)
		res, err := compute.Evaluate(input)
		if err != nil {
			fmt.Println("Error: " + err.Error())
			return
		}
		s := fmt.Sprintf("%f", res)
		fmt.Println(strings.TrimSuffix(strings.TrimRight(s, "0"), "."))
		return
	} else {
		array := make([]string, 0)
		for name := range operators.Ops {
			array = append(array, name)
		}
		sort.Strings(array)
		for _, v := range array {
			fmt.Println(v)
		}
	}

	exep := compute.NewComputer("1&&1")
	res, err := exep.Calc()
	if err != nil {
		log.Println(err)
	} else {
		log.Println(res)
	}

	exep = compute.NewComputer("1&&0")
	res, err = exep.Calc()
	if err != nil {
		log.Println(err)
	} else {
		log.Println(res)
	}

	fmt.Println()
	exep = compute.NewComputer("me*(1.1-1) + 400")
	exep.SetParamter("me", 10)
	res, err = exep.Calc()
	if err != nil {
		log.Println(err)
	} else {
		log.Println(res)
	}
	exep.SetParamter("me", 100)
	res, err = exep.Calc()
	log.Println(res)

}
